<?php
/**
* @author trungdt
* @since sep 21, 2011 
* 
* Change logs
* Sep 21, 2011 - trungdt - First create this action, based on download_file.php on the BASE
*/
	
	$file_name="";
	
	// get type and file name from URL input
	if (isset($_GET['file_name']))
	{
		$file_name=_ab_safe_html_string($_GET['file_name']);
	}
	
	// get file object
	$file = $db->selectObject('file',"filename = '{$file_name}'");    
	// increase download count
	$db->increment('documentsmodule_document','download',1,"pdf_file = {$file->id}  OR xls_file = {$file->id} OR flv_file = {$file->id} OR ppt_file = {$file->id} OR mp3_file = {$file->id} OR doc_file = {$file->id}");
	
	$filenametest = $file->directory . "/" . $file->filename;

	if (file_exists($filenametest)) {			
		header("Location: ". BASE_URL."/{$filenametest}");
		die();
	} else {
		echo SITE_404_HTML;
	}

?>
